package com.tct.worktimeboard.controller;

import com.alibaba.fastjson.JSONObject;
import com.tct.worktimeboard.entity.WorkSetting;
import com.tct.worktimeboard.service.IWorkSettingService;
import com.tct.worktimeboard.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Huhailong
 * @Description
 * @Date 2021/3/1.
 */
@RestController
@RequestMapping("/workSetting")
public class WorkSettingController {
    @Autowired
    IWorkSettingService workSettingService;

    @GetMapping("/getWorkSetList")
    public JSONObject getWorkSetList(WorkSetting workSetting){
        return workSettingService.getWorkSet(workSetting);
    }

    @PostMapping("/createWorkSet")
    public JSONObject createWorkSet(@RequestBody WorkSetting workSetting){
        return workSettingService.addWorkSet(workSetting);
    }

    @PostMapping("/deleteWorkSet")
    public JSONObject deleteWorkSet(@RequestBody List<Long> ids){
        workSettingService.removeByIds(ids);
        return JsonUtil.toJsonData();
    }

    @PostMapping("/updateWorkSet")
    public JSONObject updateWorkSet(@RequestBody WorkSetting workSetting){
        workSettingService.updateById(workSetting);
        return JsonUtil.toJsonData();
    }
}
